<?php

// Wenn man nicht die benötigten Rechte besitzt, dann darf die Seite nicht aufgerufen werden
if (!hasPermission('section=news')) {
	return new Ret(PERMISSION_DENIED. ': Missing right(s) for section=news');
}

// Die actions für news definieren
$action = array();
$action['create']	= 'news/create.php';
$action['overview']	= 'news/overview.php';	// default


$core_news_ret = new Ret();

if (isset($_GET['action'])) {
	
	if (!isset($action[$_GET['action']])) {
		
		$core_news_ret = new Ret(ERR_ACTION_DOES_NOT_EXIST. ': '. $_GET['action']);
		
		// warn
		$logger->logFile('The action '. $_GET['action'] .'does not exist for news', LEVEL_WARN);
		
	} else if (file_exists('includes/'. $action[$_GET['action']])) {
		
		// Die gewünschte action laden
		$core_news_ret = include 'includes/'. $action[$_GET['action']];
		
	} else {
		
		$core_news_ret = new Ret(INCLUDE_NOT_FOUND_EXCEPTION. ': includes/'.$action[$_GET['action']]);
		
		// error
		$logger->logFile("The include file '". 'includes/'.$action[$_GET['action']] ."' was not found.", LEVEL_ERROR);
	
	}
}

if (!$core_news_ret->get_template()) {
	
	if (file_exists('includes/'. $action['overview'])) {
		
		$core_news_ret = include 'includes/'. $action['overview'];
		
	} else {
		
		$core_news_ret = new Ret(INCLUDE_NOT_FOUND_EXCEPTION . ': includes/'.$action['overview']);
		// error
		$logger->logFile("The include file '". 'includes/'.$action['overview'] ."' was not found.", LEVEL_ERROR);
	
	}
}

return $core_news_ret;

?>